<template>
  <a-layout id="components-layout-demo-side" style="min-height: 100vh">
    <a-layout-sider theme="light" v-model="collapsed">
      <div class="logo"><h1 style="font-size: 18px;font-weight: bold;color: #1890ff;">隆源考勤管理后台</h1></div>
      <side-menu mode="inline" :menus="menus" :theme="navTheme" :collapsed="collapsed" :collapsible="true"></side-menu>
    </a-layout-sider>
    <a-layout class="layout">
      <a-layout-header style="background: #fff; padding: 0 16px">
        <a-icon
          class="trigger"
          :type="collapsed ? 'menu-unfold' : 'menu-fold'"
          @click="() => (collapsed = !collapsed)"
        />
        <user-menu></user-menu>
      </a-layout-header>
      <a-layout-content style="margin: 0 16px;overflow:auto;">
        <a-breadcrumb style="margin: 16px 0">
          <a-breadcrumb-item v-for="(item, index) in linkList" :key="index">{{ item }}</a-breadcrumb-item>
        </a-breadcrumb>

        <div :style="{ background: '#fff', height: 'calc(100% - 70px)' }">
          <router-view ref="content" />
        </div>
      </a-layout-content>
      <!-- <a-layout-footer style="text-align: center">
        Ant Design ©2018 Created by Ant UED
      </a-layout-footer> -->
    </a-layout>
  </a-layout>
</template>
<script>
import SideMenu from '@/components/Menu/SideMenu'
import UserMenu from '@/components/UserMenu'
import { getRouter, generator } from '@/router/generator-routers'
export default {
  name: 'BasicLayout',
  components: {
    SideMenu,
    UserMenu
  },
  data () {
    return {
      linkList: [],
      title: '',
      collapsed: false,
      menus: [],
      navTheme: 'light'
    }
  },
  watch: {
    $route (val) {
      if (val) {
        this.getPageMeta()
      }
    }
  },
  created () {
    const menuNav = getRouter()
    menuNav[0].children = generator(this.$store.state.menuList)
    this.menus = menuNav.find(item => item.path === '/').children
    // console.log(this.menus)
    this.getPageMeta()
  },
  methods: {
    getPageMeta () {
      this.pageTitle = this.$route.meta.pageTitle
      if (this.pageTitle) {
        this.linkList = this.pageTitle.split('/')
      }
    }
  }
}
</script>

<style>
#components-layout-demo-side .logo {
  height: 32px;
  background: rgba(255, 255, 255, 0.2);
  margin: 16px;
  -webkit-transition: all 0.3s;
  transition: all 0.3s;
  text-align: center;
}
#components-layout-demo-side.trigger {
  font-size: 18px;
  line-height: 64px;
  padding: 0 24px;
  cursor: pointer;
  transition: color 0.3s;
}

#components-layout-demo-side .trigger:hover {
  color: #1890ff;
}
</style>

<style lang="less">
@import url('../assets/css/global.less');

/*
 * The following styles are auto-applied to elements with
 * transition="page-transition" when their visibility is toggled
 * by Vue.js.
 *
 * You can easily play with the page transition by editing
 * these styles.
 */

.page-transition-enter {
  opacity: 0;
}

.page-transition-leave-active {
  opacity: 0;
}

.page-transition-enter .page-transition-container,
.page-transition-leave-active .page-transition-container {
  -webkit-transform: scale(1.1);
  transform: scale(1.1);
}
.ant-layout-content {
  height: calc(100vh - 64px);
}
</style>
